<template>
  <div class="app-container search-list model-with-line">
    <el-tabs v-model="activeName" @tab-click="handleClick">
      <el-tab-pane label="订单通知" name="first">
        <el-table :data="orderList" style="width: 100%">
          <el-table-column label="名称" prop="detailTypeName"></el-table-column>
          <el-table-column label="备注" prop="remark"></el-table-column>
          <el-table-column label="描述" prop="description"></el-table-column>
          <!--          <el-table-column label="设置" width="200">-->
          <!--            <template slot-scope="{row}">-->
          <!--              <el-switch v-model="row.state" active-color="#13ce66" active-text="启用"-->
          <!--                         inactive-color="lightgrey" inactive-text="禁用" @change="changeState(row)">-->
          <!--              </el-switch>-->
          <!--            </template>-->
          <!--          </el-table-column>-->
          <!--          <el-table-column label="状态" width="100">-->
          <!--            <template slot-scope="scope">-->
          <!--              <el-button plain size="mini" type="primary" @click="preView(scope.row.id)">预览</el-button>-->
          <!--            </template>-->
          <!--          </el-table-column>-->
          <el-table-column label="状态" prop="statusText"></el-table-column>
        </el-table>
      </el-tab-pane>
      <el-tab-pane label="顾客通知" name="second">
        <el-table :data="memberList" style="width: 100%">
          <el-table-column label="名称" prop="detailTypeName"></el-table-column>
          <el-table-column label="备注" prop="remark"></el-table-column>
          <el-table-column label="描述" prop="description"></el-table-column>
          <!--          <el-table-column label="设置" width="200">-->
          <!--            <template slot-scope="{row}">-->
          <!--              <el-switch v-model="row.state" active-color="#13ce66" active-text="启用"-->
          <!--                         inactive-color="lightgrey" inactive-text="禁用" @change="changeState(row)">-->
          <!--              </el-switch>-->
          <!--            </template>-->
          <!--          </el-table-column>-->
          <!--          <el-table-column label="状态" width="100">-->
          <!--            <template slot-scope="scope">-->
          <!--              <el-button plain size="mini" type="primary" @click="preView(scope.row.id)">预览</el-button>-->
          <!--            </template>-->
          <!--          </el-table-column>-->
          <el-table-column label="状态" prop="statusText"></el-table-column>
        </el-table>
      </el-tab-pane>
      <el-tab-pane label="营销通知" name="third">
        <el-table :data="marketList" style="width: 100%">
          <el-table-column label="名称" prop="detailTypeName"></el-table-column>
          <el-table-column label="备注" prop="remark"></el-table-column>
          <el-table-column label="描述" prop="description"></el-table-column>
          <!--          <el-table-column label="设置" width="200">-->
          <!--            <template slot-scope="{row}">-->
          <!--              <el-switch v-model="row.state" active-color="#13ce66" active-text="启用"-->
          <!--                         inactive-color="lightgrey" inactive-text="禁用" @change="changeState(row)">-->
          <!--              </el-switch>-->
          <!--            </template>-->
          <!--          </el-table-column>-->
          <!--          <el-table-column label="状态" width="100">-->
          <!--            <template slot-scope="scope">-->
          <!--              <el-button plain size="mini" type="primary" @click="preView(scope.row.id)">预览</el-button>-->
          <!--            </template>-->
          <!--          </el-table-column>-->
          <el-table-column label="状态" prop="statusText"></el-table-column>
          <el-table-column
              fixed="right"
              label="操作"
              width="100">
            <template >
              <el-button type="text" @click="dialogFormVisible = true">设置优惠码</el-button>
            </template>
          </el-table-column>
        </el-table>
      </el-tab-pane>
    </el-tabs>
    <el-dialog title="优惠码设置" :visible.sync="dialogFormVisible">
<!--      <el-form :model="scope.row">-->
<!--        <el-form-item label="活动区域" :label-width="formLabelWidth">-->
<!--          <el-select v-model="scope.row" placeholder="请选择活动区域">-->
<!--            <el-option label="区域一" value="shanghai"></el-option>-->
<!--            <el-option label="区域二" value="beijing"></el-option>-->
<!--          </el-select>-->
<!--        </el-form-item>-->
<!--      </el-form>-->
<!--      <div slot="footer" class="dialog-footer">-->
<!--        <el-button @click="dialogFormVisible = false">取 消</el-button>-->
<!--        <el-button @click="editData(scope.row)" type="text" size="small">确定保存</el-button>-->
<!--      </div>-->
    </el-dialog>
  </div>
</template>
<script>
import {getInformList, updateSetting} from '@/api/inform';

export default {
    data () {
        return {
            activeName: 'first',
            orderList: [],
            memberList: [],
            marketList: [],
            params: {},
            dialogFormVisible: false,
            form: {
                name: '',
                region: '',
                date1: '',
                date2: '',
                delivery: false,
                type: [],
                resource: '',
                desc: ''
            },
            formLabelWidth: '120px'
        };
    },
    methods: {
        handleClick (tab, event) {
            console.log(tab, event);
        },
        getInformList () {
            this.params.siteId = this.siteId;
            getInformList(this.params).then(res => {
                console.info(res.data);
                this.orderList = res.data.orderList;
                this.memberList = res.data.memberList;
                this.marketList = res.data.marketList;
            });
        },

        preView () {
            alert('模板未开发完成');
        },
        editData (obj) {
            updateSetting(obj).then(res => {
                if (res.code === '200') {
                    this.$message({
                        type: 'success',
                        message: '操作成功!'
                    });
                }
            });
        }
    // changeState (obj) {
    //     if (obj.state) {
    //         this.$confirm('此操作将启用设置, 是否继续?', '提示', {
    //             confirmButtonText: '确定',
    //             cancelButtonText: '取消',
    //             type: 'warning'
    //         }).then(() => {
    //             updateSetting(obj).then(res => {
    //                 if (res.code === '200') {
    //                     this.$message({
    //                         type: 'success',
    //                         message: '启用成功!'
    //                     });
    //                 } else {
    //                     obj.state = false;
    //                     this.$message({
    //                         type: 'error',
    //                         message: '启用失败!'
    //                     });
    //                 }
    //             });
    //         }).catch(() => {
    //             this.$message({
    //                 type: 'info',
    //                 message: '已取消启用'
    //             });
    //             obj.state = false;
    //         });
    //     } else {
    //         this.$confirm('此操作将禁用设置, 是否继续?', '提示', {
    //             confirmButtonText: '确定',
    //             cancelButtonText: '取消',
    //             type: 'warning'
    //         }).then(() => {
    //             updateSetting(obj).then(res => {
    //                 if (res.code === '200') {
    //                     this.$message({
    //                         type: 'success',
    //                         message: '禁用成功!'
    //                     });
    //                 } else {
    //                     obj.state = false;
    //                     this.$message({
    //                         type: 'error',
    //                         message: '禁用失败!'
    //                     });
    //                 }
    //             });
    //         }).catch(() => {
    //             this.$message({
    //                 type: 'info',
    //                 message: '已取消禁用'
    //             });
    //             obj.state = true;
    //         });
    //     }
    //     console.info(obj);
    // }
    },
    created () {
        this.getInformList();
    },
    computed: {
        siteId () {
            return this.$store.state.user.siteId;
        }
    }
};
</script>
